from common.models import User
from common.utils import uid_to_openid
from django.http import JsonResponse


# 热门律师
def get_hot_lawyers(request):
    # if request.method == "GET":
    #     print("")
    # elif request.method == "POST":
    #     print("")
    # else:
    #     print("")
    # lawyers = Lawyer.objects.values()
    # data = list(lawyers)
    return JsonResponse({
        "code": "200",
        "msg": "success",
        "data": "get_hot_lawyers test",
    })


def update_userinfo(request):
    uid = request.POST.get("uid")
    avatar = request.POST.get("avatar")
    user = User.objects.get(uid=uid_to_openid(uid))
    user.avatar = avatar
    print(avatar)
    # user.save()
    print(user)

    return JsonResponse({
        "code": "200",
        "msg": "success",
        "data": "data",
    })
